package ObjectOriented;

/**
 * ClassName:GirlFriend
 * Package:object_oriented
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/1/14-11:07
 * @Version:v1.0
 */
public class GirlFriend {
    private String name;
    private int age;
    private String gender;
    //针对每一个私有化的成员变量,都提供get和set方法
    //set方法:给成员变量赋值
    //get方法:对外提供成员变量的值

    public void setName(String name) {
        //局部变量表示测试类中调用的方法传递过来的数据
        //等号的左边：就表示成员位置的name
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setAge(int age) {
        if (age >= 18 && age <= 50) {
            this.age = age;
        } else {
            System.out.println("非法参数");
        }
    }

    public int getAge() {
        return age;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getGender() {
        return gender;
    }

    public void eat() {
        System.out.println("我会吃饭,不停地炫饭");
    }

    public void sleep() {
        System.out.println("我喜欢睡觉");
    }
}
